package com.i72.penetrate.blance;

import com.i72.governance.service.bean.ServiceNode;

import java.util.List;
import java.util.Random;

public class RandomBlance implements RPCBlance {

    @Override
    public ServiceNode voteNode(List<ServiceNode> serviceNodes) {
        if(serviceNodes!=null && serviceNodes.size()>0) {
            int MAX = serviceNodes.size() - 1;
            int MIN = 0;
            Random rand = new Random();
            int randNumber = rand.nextInt(MAX - MIN + 1) + MIN;

            return serviceNodes.get(randNumber);
        }
        return null;
    }
}
